﻿using UnityEngine;
using System.Collections;

namespace AutoRoot
{
   public class Decision : ButtonStateHandler
   {
      public string branch;

      public override void Execute()
      {
         //get correct branch id
         string id = Global.currentSection.Value.id + branch;

         Global.currentSection = Global.myStory.GetLast();
         Global.LoadAudio(Global.currentSection.Value.resourcePath);

         GameObject.Find("ControlPart").SendMessage("OnPlaySection", SendMessageOptions.DontRequireReceiver);

         GameObject.Find("Progressbar").SendMessage("updateTotalTime", Global.currentAudio.clip.length, SendMessageOptions.DontRequireReceiver);

         Global.currentAudio.time = 0;
         GameObject.Find("ButtonPlayOrPause").GetComponent<Play>().Execute();
      }
   }
}
